<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="/js/ajax.aspnetcdn.com_ajax_jquery_jquery-1.9.0.min.js"></script>

    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
    <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
    <style>
        body {
            background: url("/img/v2-4140af78cd90201a338a189ad7dbeda6_r.jpg") no-repeat;
            background-size: 100% 130%;
        }

        #login_box {
            width: 20%;
            height: 400px;
            background-color: #00000060;
            margin: auto;
            margin-top: 10%;
            text-align: center;
            border-radius: 10px;
            padding: 50px 50px;
        }

        h2 {
            color: #ffffff90;
            margin-top: 5%;
        }

        #input-box {
            margin-top: 5%;
        }

        span {
            color: #fff;
        }

        #username, #password {
            border: 0;
            width: 60%;
            font-size: 15px;
            color: #fff;
            background: transparent;
            border-bottom: 2px solid #fff;
            padding: 5px 10px;
            outline: none;
            margin-top: 10px;
        }

        button {
            margin-top: 50px;
            width: 60%;
            height: 30px;
            border-radius: 10px;
            border: 0;
            color: #fff;
            text-align: center;
            line-height: 30px;
            font-size: 15px;
            background-image: linear-gradient(to right, #30cfd0, #330867);
        }

        #sign_up {
            margin-top: 45%;
            margin-left: 60%;
        }

        #re {
            background: transparent;

        }
        #register{
            margin-top: 50px;
            width: 60%;
            height: 30px;
            border-radius: 10px;
            border: 0;
            color: #fff;
            text-align: center;
            line-height: 30px;
            font-size: 15px;
            background-image: linear-gradient(to right, #30cfd0, #330867);
        }
        a {
            color: #b94648;
        }

    </style>
</head>

<body>


<div id="login_box">
    <form id="form1" th:action="@{/user/login}" method="post">
        <h2>登录</h2>
        <div class="alert alert-success" role="alert" align="center">
        <span style="color: red" th:text="${msg}" th:if="${not #strings.isEmpty(msg)}"></span>
        </div>
        <div id="input_box">
            <input id="username" type="text" name="username" placeholder="请输入用户名">
        </div>
        <div class="input_box">
            <input id="password" type="password" name="password" placeholder="请输入密码">
        </div>
        <button id="loginbuttom" type="submit" >登录</button>
        <br>
        <button id="register" type="button" onclick="window.location.href='/register'">注册</button>
    </form>

</div>

<!--<script>-->
<!--    $(document).ready(function (){-->
<!--        $("#loginbuttom").click(function (){-->
<!--            login();-->
<!--        })-->
<!--    });-->


<!--    function login() {-->

<!--            $.ajax({-->
<!--                url:"/user/login",-->
<!--                type:"POST",-->
<!--                data:$("#form1").serialize(),-->
<!--                dataType:"JSON",-->
<!--                success(result){-->
<!--                    console.log(result)-->
<!--                    if (result.admin==1){-->
<!--                        alert("欢迎管理员登入")-->
<!--                        location.href="index.html"-->
<!--                    }else{-->
<!--                        alert("欢迎用户登入")-->
<!--                        location.href="index.html"-->

<!--                    }-->


<!--                },-->
<!--                error:function (xhr){-->
<!--                    alert(xhr.status)-->
<!--                }-->
<!--            })-->


<!--        }-->

<!--</script>-->
</body>
</html>